<?php
	session_start();
	require_once("db_connect.php");

	$manager_id = $_SESSION["manager_id"];
	$old_pass  = htmlspecialchars($_POST['old_pass'],ENT_QUOTES,"UTF-8");
	$new_pass   = htmlspecialchars($_POST['new_pass'],ENT_QUOTES,"UTF-8");

	$sql = "UPDATE manager
			SET password = ?
			WHERE manager_id = ?
			AND password = ?";

	$stmt = $db->prepare($sql);

	$data = array($new_pass,
	              $manager_id,
	              $old_pass
	);

	$res =& $db->execute($stmt, $data);	//SQLを実行して、結果を $res に代入
	if (PEAR::isError($res)) {			//SQLの実行に失敗すればここでエラー文を出力
		die($res->getMessage());
		echo error;
	}

	header("Location: ../maanger_index.php");
?>